/**
 * Created by liujie on 2016/8/25.
 */
//倒计时，单位毫秒
var time_desc;
var time_stop = false;
function startTimer(ts){
    time_desc = new Date();
    time_desc.setTime(time_desc.getTime()+ts);
    time_stop = false;
    timer();
}
function timer() {
    if (time_stop) {
        $("#min_label").html("00");
        $("#sec_label").html("00");
    } else {
        var ts = time_desc.getTime() - (new Date());//计算剩余的毫秒数
        var mm = parseInt(ts / 1000 / 60, 10);//计算剩余的分钟数
        var ss = parseInt(ts / 1000 % 60, 10);//计算剩余的秒数
        mm = checkTime(mm);
        ss = checkTime(ss);
        $("#min_label").html(mm);
        $("#sec_label").html(ss);
        if (mm > 0 || ss > 0) {
            window.setTimeout("timer()", 1000);
        } else {
            alert("时间到！");
            submitExam();//交卷
        }
    }
}
function checkTime(i)
{
    if (i < 10) {
        i = "0" + i;
    }
    return i;
}

function stopTime(){
    time_stop = true;
}